/*	kd:
	
	Allows interpolating through several values linearly in sequence (parameter
	way, could be optimised by assuming max_val rarely changes).
	
	*/

class FontColorStage {
	protected Array <int>				colors;
	protected int						size;
	protected int						max_index;
	
	protected void CacheSize () {
		size = colors.size();
		max_index = max(0, size - 1);
	}
	
	// The two colours and how much we're between them:
	int, int, double Get (int val, int max_val) const {
		int delta	= max(1, max_val / max_index);
		int closest	= MiscOps.ClosestMultiple(val, delta);
		int i		= closest * size / max_val;
		
		return	colors [clamp(i, 0, max_index)],
				colors [clamp(i + 1, 0, max_index)],
				(double)(val - closest) / (delta);
	}
}

// kd: We use these for the health viewer.

class RedFontStages : FontColorStage {
	void Init () {
		colors.push(Font.cr_red);
		colors.push(Font.cr_orange);
		colors.push(Font.cr_yellow);
		colors.push(Font.cr_green);
		CacheSize();
	}
}

class BlueFontStages : FontColorStage {
	void Init () {
		colors.push(Font.cr_grey);
		colors.push(Font.cr_ice);
		colors.push(Font.cr_lightblue);
		colors.push(Font.cr_sapphire);
		colors.push(Font.cr_cyan);
		CacheSize();
	}
}

class GreenFontStages : FontColorStage {
	void Init () {
		colors.push(Font.cr_darkgray);
		colors.push(Font.cr_darkgreen);
		colors.push(Font.cr_green);
		CacheSize();
	}
}